package com.jxtech.hp.vdps.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * WebMvc配置
 *
 * @author Mark sunlightcs@gmail.com
 * @since 3.0.0 2018-01-25
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {

  @Value("${uploadPath}")
  private String uploadPath;

  @Value("${uploadUrl}")
  private String uploadUrl;

  @Override
  public void addResourceHandlers(ResourceHandlerRegistry registry) {
    registry.addResourceHandler("/statics/**").addResourceLocations("classpath:/statics/");

    //映射本地上传文件夹为静态资源文件
    registry.addResourceHandler(uploadUrl + "**").addResourceLocations(
        "file:" + uploadPath);

  }
}
